#pragma once
#include <QImage>
#include <nlohmann/json.hpp>
#include <string>
#include "qlib/all.h"

namespace qbe::UiMessage {

enum struct LayerCode { New, Update, Ui_Add, UI_NewLayerStyleDefine };

struct LayerEvent {
  LayerCode code;
  nlohmann::json data;
};

struct LayerItemInfo {
  std::string layer_name;    //图层名
  uint32_t layer_number;     //图层编号
  std::string qlb_type;      // 区别版图和原理图
  std::string fill_color;    //填充颜色
  std::string border_color;  //边框颜色
  std::string fill_shape;    //填充形状
  std::string border_shape;  //边框形状
  bool layer_lock = false;   //是否锁定
  bool layer_hide = false;   //是否隐藏
  bool layer_export = true;  //是否导出
  QImage layer_image;
};

//打开版图后加载图层
struct GetLibLayerMap {
  std::map<uint32_t, LayerItemInfo> libLayerMap;
};

//新增图层
struct CreateNewLayer {
  uint32_t new_layer_number;  //新增图层编号
  LayerItemInfo layer;        //新增后的图层
};

//编辑图层样式/名称
struct EditLayer {
  uint32_t edit_layer_number;  //被编辑的图层的编号
  LayerItemInfo layer;         //编辑后的图层
};

//编辑图层编号
struct EditLayerNumber {
  uint32_t old_layer_number;  //旧编号
  uint32_t new_layer_number;  //新编号
  LayerItemInfo layer;        //编辑后的图层
};

//删除图层
struct DeleteLayer {
  std::vector<uint32_t> delete_layer_numbers;  //被删除的图层编号
};

//合并图层
struct MergeLayer {
  uint32_t merge_to_layer;             //合并到图层编号
  std::vector<uint32_t> merge_layers;  //被合并的图层编号集合
  int deep;                            //合并操作范围 0为当前画板对象 -1为所有下层对象
};

//清除图层
struct ClearLayer {
  std::vector<uint32_t> clear_layers;  //被清除的图层编号集合
  int deep;                            //合并操作范围 0为当前画板对象 -1为所有下层对象
};

//图层切换
struct ChangeLayer {
  bool have_use_layer = true;
  uint32_t change_to_layer;  //切换到的图层编号
};

//图层隐藏
struct HideLayer {
  uint32_t hide_layer;     //被隐藏的图层编号
  bool hide_layer_status;  //图层是否隐藏
};

//内核通知图层更新
struct LayerUpdate {};

}  // namespace qbe::UiMessage